<template>
    <div class="achieveBasicInfo container">
        <div id="components-form-demo-advanced-search">
            <div class="tabCommonTitle">
                <span>申报表</span>
            </div>
            <!-- 专利质量评价材料 -->
            <div class="declareTableInfo">
                <div class="title">
                    <span v-if="xl_id!='5103'">专利质量评价材料<em>（请上传doc格式，2500字以内）</em></span>
                    <span v-else-if="xl_id=='5103'">专利质量评价材料<em>（请上传doc格式，2000字以内）</em></span>
                    <div class="flex_box">
                        <div style="width: 200px;">
                            <a-progress :percent="zlpj_percent" v-show="zlpj_percent_flag"/>
                        </div>
                        <div class="btnList">
                            <a-button class="loadboard" @click="loadboard_zlpj">模板下载</a-button>
                            <a-button @click="handlePreview_zlpj" :disabled="zlpjlist&&zlpjlist.id?false:true">预览</a-button>
                            <!-- <a-button @click="fileload_zlpj" :disabled="zlpjlist&&zlpjlist.id?false:true">下载</a-button> -->
                            <a-button :class="is_modify=='Y'?'download':''" @click="handleDownload_zlpj" type="primary" :disabled="is_modify=='Y'?false:true">上传</a-button>
                            <input type="file" class="pointer zlpj" id="zlpj" accept=".doc" value="上传" @change="handleDownloadzlpj"/>
                        </div>
                    </div>
                    <!-- <a-progress :percent="zlpj_percent" v-show="zlpj_percent_flag"/> -->
                </div>
                <div class="tableList">
                    <table style="text-align:center;" width="1110"  align="center" cellpadding="">
                        <thead>
                            <tr>
                                <th>是否上传成功</th>
                                <th>文件大小（M）</th>
                                <th>文件类型</th>
                                <th>当前字数</th>
                            </tr>
                        </thead>
                        <tbody v-if="zlpjlist&&zlpjlist.id">
                            <tr>
                                <td>{{zlpjlist.filePdfpath!='' ?'成功':''}}</td>
                                <td>{{zlpjlist.fileSize}}</td>
                                <td>{{zlpjlist.fileType}}</td>
                                <td>{{zlpjlist.fileNumber}}</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <!-- 设计要点及理念的表达评价材料 -->
            <div class="declareTableInfo" v-if="xl_id=='5103'">
                <div class="title">
                    <span>设计要点及理念的表达评价材料<em>（请上传doc格式，2000字以内）</em></span>
                    <div class="flex_box">
                        <div style="width: 200px;"> 
                            <a-progress :percent="sjyd_percent" v-show="sjyd_percent_flag"/>
                        </div>
                        <div class="btnList">
                            <a-button class="loadboard" @click="loadboard_sjyd">模板下载</a-button>
                            <a-button @click="handlePreview_sjyd" :disabled="sjydlist&&sjydlist.id?false:true">预览</a-button>
                            <!-- <a-button @click="fileload_sjyd" :disabled="sjydlist&&sjydlist.id?false:true">下载</a-button> -->
                            <a-button :class="is_modify=='Y'?'download':''" @click="handleDownload_sjyd" type="primary" :disabled="is_modify=='Y'?false:true">上传</a-button>
                            <input type="file" class="pointer sjyd" id="sjyd" accept=".doc" value="上传" @change="handleDownloadsjyd"/>
                        </div>
                    </div>
                </div>
                <div class="tableList">
                    <table style="text-align:center;" width="1110"  align="center" cellpadding="">
                        <thead>
                            <tr>
                                <th>是否上传成功</th>
                                <th>文件大小（M）</th>
                                <th>文件类型</th>
                                <th>当前字数</th>
                            </tr>
                        </thead>
                        <tbody v-if="sjydlist&&sjydlist.id">
                            <tr>
                                <td>{{sjydlist.filePdfpath!='' ?'成功':''}}</td>
                                <td>{{sjydlist.fileSize}}</td>
                                <td>{{sjydlist.fileType}}</td>
                                <td>{{sjydlist.fileNumber}}</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <!-- 技术先进性评价材料 -->
            <div class="declareTableInfo" v-if="xl_id!='5103'">
                <div class="title">
                    <span>技术先进性评价材料<em>（请上传doc格式，3000字以内）</em></span>
                    <div class="flex_box">
                        <div style="width: 200px;">
                            <a-progress :percent="jsxjx_percent" v-show="jsxjx_percent_flag"/>
                        </div>
                        <div class="btnList">
                            <a-button class="loadboard" @click="loadboard_jsxjx">模板下载</a-button>
                            <a-button @click="handlePreview_jsxjx" :disabled="jsxjxlist&&jsxjxlist.id?false:true">预览</a-button>
                            <!-- <a-button @click="fileload_jsxjx" :disabled="jsxjxlist&&jsxjxlist.id?false:true">下载</a-button> -->
                            <a-button :class="is_modify=='Y'?'download':''" type="primary" @click="handleDownload_jsxjx" :disabled="is_modify=='Y'?false:true">上传</a-button>
                            <input type="file" class="pointer jsxjx" id="jsxjx" accept=".doc" value="上传" @change="handleDownloadjsxjx"/>
                        </div>
                    </div>
                </div>
                <div class="tableList">
                    <table style="text-align:center;" width="1110"  align="center" cellpadding="">
                        <thead>
                            <tr>
                                <th>是否上传成功</th>
                                <th>文件大小（M）</th>
                                <th>文件类型</th>
                                <th>当前字数</th>
                            </tr>
                        </thead>
                        <tbody v-if="jsxjxlist&&jsxjxlist.id">
                            <tr>
                                <td>{{jsxjxlist.filePdfpath!='' ?'成功':''}}</td>
                                <td>{{jsxjxlist.fileSize}}</td>
                                <td>{{jsxjxlist.fileType}}</td>
                                <td>{{jsxjxlist.fileNumber}}</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <!-- 保护措施和成效评价1 -->
            <div class="declareTableInfo">
                <div class="title">
                    <span v-if="xl_id!='5103'">保护措施和成效评价1<em>（请上传doc格式，3000字以内）</em></span>
                    <span v-else>保护措施和成效评价1<em>（请上传doc格式，2500字以内）</em></span>
                    <div class="flex_box">
                        <div style="width: 200px;">
                            <a-progress :percent="bhcx1_percent" v-show="bhcx1_percent_flag"/>
                        </div>
                        <div class="btnList">
                            <a-button class="loadboard" @click="loadboard_bhcx1">模板下载</a-button>
                            <a-button @click="handlePreview_bhcx1" :disabled="bhcx1list&&bhcx1list.id?false:true">预览</a-button>
                            <!-- <a-button @click="fileload_bhcx1" :disabled="bhcx1list&&bhcx1list.id?false:true">下载</a-button> -->
                            <a-button :class="is_modify=='Y'?'download':''" @click="handleDownload_bhcx1" type="primary" :disabled="is_modify=='Y'?false:true">上传</a-button>
                            <input type="file" class="pointer bhcx1" id="bhcx1" accept=".doc" value="上传" @change="handleDownloadbhcx1"/>
                        </div>
                    </div>
                </div>
                <div class="tableList">
                    <table style="text-align:center;" width="1110"  align="center" cellpadding="">
                        <thead>
                            <tr>
                                <th>是否上传成功</th>
                                <th>文件大小（M）</th>
                                <th>文件类型</th>
                                <th>当前字数</th>
                            </tr>
                        </thead>
                        <tbody v-if="bhcx1list&&bhcx1list.id">
                            <tr>
                                <td>{{bhcx1list.filePdfpath!='' ?'成功':''}}</td>
                                <td>{{bhcx1list.fileSize}}</td>
                                <td>{{bhcx1list.fileType}}</td>
                                <td>{{bhcx1list.fileNumber}}</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <!-- 保护措施和成效评价2 -->
            <div class="declareTableInfo">
                <div class="title">
                    <span>保护措施和成效评价2<em>（请上传doc格式，500字以内）</em></span>
                    <div class="flex_box">
                        <div style="width: 200px;">
                            <a-progress :percent="bhcx2_percent" v-show="bhcx2_percent_flag"/>
                        </div>
                        <div class="btnList">
                            <a-button class="loadboard" @click="loadboard_bhcx2">模板下载</a-button>
                            <a-button @click="handlePreview_bhcx2" :disabled="bhcx2list&&bhcx2list.id?false:true">预览</a-button>
                            <!-- <a-button @click="fileload_bhcx2" :disabled="bhcx2list&&bhcx2list.id?false:true">下载</a-button> -->
                            <a-button :class="is_modify=='Y'?'download':''" @click="handleDownload_bhcx2" type="primary" :disabled="is_modify=='Y'?false:true">上传</a-button>
                            <input type="file" class="pointer bhcx2" id="bhcx2" accept=".doc" value="上传" @change="handleDownloadbhcx2"/>
                        </div>
                    </div>
                </div>
                <div class="tableList">
                    <table style="text-align:center;" width="1110"  align="center" cellpadding="">
                        <thead>
                            <tr>
                                <th>是否上传成功</th>
                                <th>文件大小（M）</th>
                                <th>文件类型</th>
                                <th>当前字数</th>
                            </tr>
                        </thead>
                        <tbody v-if="bhcx2list&&bhcx2list.id">
                            <tr>
                                <td>{{bhcx2list.filePdfpath!='' ?'成功':''}}</td>
                                <td>{{bhcx2list.fileSize}}</td>
                                <td>{{bhcx2list.fileType}}</td>
                                <td>{{bhcx2list.fileNumber}}</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <!-- 社会效益及发展前景评价 -->
            <div class="declareTableInfo">
                <div class="title">
                    <span v-if="xl_id!='5103'">社会效益及发展前景评价<em>（请上传doc格式，2500字以内）</em></span>
                    <span v-else>社会效益及发展前景评价<em>（请上传doc格式，3000字以内）</em></span>
                    <div class="flex_box">
                        <div style="width: 200px;">
                            <a-progress :percent="shxy_percent" v-show="shxy_percent_flag"/>
                        </div>
                        <div class="btnList">
                            <a-button class="loadboard" @click="loadboard_shxy">模板下载</a-button>
                            <a-button @click="handlePreview_shxy" :disabled="shxylist&&shxylist.id?false:true">预览</a-button>
                            <!-- <a-button @click="fileload_shxy" :disabled="shxylist&&shxylist.id?false:true">下载</a-button> -->
                            <a-button :class="is_modify=='Y'?'download':''" @click="handleDownload_shxy" type="primary" :disabled="is_modify=='Y'?false:true">上传</a-button>
                            <input type="file" class="pointer shxy" id="shxy" accept=".doc" value="上传" @change="handleDownloadshxy"/>
                        </div>
                    </div>
                </div>
                <div class="tableList">
                    <table style="text-align:center;" width="1110"  align="center" cellpadding="">
                        <thead>
                            <tr>
                                <th>是否上传成功</th>
                                <th>文件大小（M）</th>
                                <th>文件类型</th>
                                <th>当前字数</th>
                            </tr>
                        </thead>
                        <tbody v-if="shxylist&&shxylist.id">
                            <tr>
                                <td>{{shxylist.filePdfpath!='' ?'成功':''}}</td>
                                <td>{{shxylist.fileSize}}</td>
                                <td>{{shxylist.fileType}}</td>
                                <td>{{shxylist.fileNumber}}</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <!-- 获奖情况 -->
            <div class="declareTableInfo">
                <div class="title">
                    <span >获奖情况<em>（请上传doc格式，500字以内）</em></span>
                    <div class="flex_box">
                        <div style="width: 200px;">
                            <a-progress :percent="hjqk_percent" v-show="hjqk_percent_flag"/>
                        </div>
                        <div class="btnList">
                            <a-button class="loadboard" @click="loadboard_hjqk">模板下载</a-button>
                            <a-button @click="handlePreview_hjqk" :disabled="hjqklist&&hjqklist.id?false:true">预览</a-button>
                            <!-- <a-button @click="fileload_hjqk" :disabled="hjqklist&&hjqklist.id?false:true">下载</a-button> -->
                            <a-button :class="is_modify=='Y'?'download':''" @click="handleDownload_hjqk" type="primary" :disabled="is_modify=='Y'?false:true">上传</a-button>
                            <input type="file" class="pointer hjqk" id="hjqk" accept=".doc" value="上传" @change="handleDownloadhjqk"/>
                        </div>
                    </div>
                </div>
                <div class="tableList">
                    <table style="text-align:center;" width="1110"  align="center" cellpadding="">
                        <thead>
                            <tr>
                                <th>是否上传成功</th>
                                <th>文件大小（M）</th>
                                <th>文件类型</th>
                                <th>当前字数</th>
                            </tr>
                        </thead>
                        <tbody v-if="hjqklist&&hjqklist.id">
                            <tr>
                                <td>{{hjqklist.filePdfpath!='' ?'成功':''}}</td>
                                <td>{{hjqklist.fileSize}}</td>
                                <td>{{hjqklist.fileType}}</td>
                                <td>{{hjqklist.fileNumber}}</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <!-- <div class="showpdf" v-if="showpdf">
            <img class="closebtn pointer" @click="closepdf" src="@/assets/img/close1.png"/>
            <testPdf :cxj_cxj_id="cxj_cxj_id" :file-path="filePath"></testPdf>
        </div> -->
        <testPdf :cxj_cxj_id="cxj_cxj_id" :file-path="filePath" :showPdf="showpdf"></testPdf>
    </div>
</template>
<script>
import {
    zlsb_getZlpj,
    zlsb_zlpjAdd,
    cxjsb_downloadZlpjmb,
    zlsb_getJsxjx,
    zlsb_jsxjxAdd,
    cxjsb_downloadJsxjxmb,
    zlsb_getShxy,
    zlsb_shxyAdd,
    cxjsb_downloadShxymb_zl,
    zlsb_getHjqk,
    zlsb_hjqkAdd,
    cxjsb_downloadHjqkmb,
    zlsb_getSjyd,
    zlsb_sjydAdd,
    cxjsb_downloadSjydmb,
    zlsb_bh1Add,
    zlsb_getBh1,
    cxjsb_downloadBh1mb,
    zlsb_bh2Add,
    zlsb_getBh2,
    cxjsb_downloadBh2mb,
    fileDownload,
    cxjsbGetCxjByid
} from '@/api/shenbao';
import testPdf from '@/views/declarationSystem/declare/testPdf';

export default {
    props: ['is_modify'],
    data() {
        return {
            cxj_cxj_id: '',
            zlpjlist: {},
            jsxjxlist: {},
            bhcx1list: {},
            bhcx2list: {},
            shxylist: {},
            hjqklist: {},
            sjydlist: {},
            cxjinfo: {},
            xl_id: '',
            zlpj_percent: 0,
            zlpj_percent_flag:false,
            jsxjx_percent: 0,
            jsxjx_percent_flag:false,
            bhcx1_percent: 0,
            bhcx1_percent_flag:false,
            bhcx2_percent: 0,
            bhcx2_percent_flag:false,
            shxy_percent: 0,
            shxy_percent_flag:false,
            hjqk_percent: 0,
            hjqk_percent_flag:false,
            sjyd_percent: 0,
            sjyd_percent_flag:false,
            showpdf: false,
            filePath: '',  
        }
    },
    props: ['is_modify'],
    components: {
        testPdf
    },
    methods: {
        handlePreview(){},
        handleUpload(){},
        handleDownload(){},
        init(){
            this.get_zlsb_getZlpj();
            this.get_zlsb_getJsxjx();
            this.get_zlsb_getBh1();
            this.get_zlsb_getBh2();
            this.get_zlsb_getShxy();
            this.get_zlsb_getHjqk();
            this.get_zlsb_getSjyd();
        },
        get_zlsb_getZlpj() {
            let that = this;
            zlsb_getZlpj(that.cxj_cxj_id).then(res=>{
                if (res.data.code=='200') {
                    that.zlpjlist = res.data.result;
                }
            })
        },
        get_zlsb_getJsxjx() {
            let that = this;
            zlsb_getJsxjx({cxj_cxj_id:that.cxj_cxj_id}).then(res=>{
                if (res.data.code=='200') {
                    that.jsxjxlist = res.data.result;
                }
            })
        },
        get_zlsb_getBh1() {
            let that = this;
            zlsb_getBh1({cxj_cxj_id:that.cxj_cxj_id}).then(res=>{
                if (res.data.code=='200') {
                    that.bhcx1list = res.data.result;
                }
            })
        },
        get_zlsb_getBh2() {
            let that = this;
            zlsb_getBh2({cxj_cxj_id:that.cxj_cxj_id}).then(res=>{
                if (res.data.code=='200') {
                    that.bhcx2list = res.data.result;
                }
            })
        },
        get_zlsb_getShxy() {
            let that = this;
            zlsb_getShxy({cxj_cxj_id:that.cxj_cxj_id}).then(res=>{
                if (res.data.code=='200') {
                    that.shxylist = res.data.result;
                }
            })
        },
        get_zlsb_getHjqk() {
            let that = this;
            zlsb_getHjqk({cxj_cxj_id:that.cxj_cxj_id}).then(res=>{
                if (res.data.code=='200') {
                    that.hjqklist = res.data.result;
                }
            })
        },
        get_zlsb_getSjyd() {
            let that = this;
            zlsb_getSjyd({cxj_cxj_id:that.cxj_cxj_id}).then(res=>{
                if (res.data.code=='200') {
                    that.sjydlist = res.data.result;
                }
            })
        },
        loadboard_zlpj() {
            let that = this;
            cxjsb_downloadZlpjmb({cxj_cxj_id:that.cxj_cxj_id}).then(res=>{
                that.downfn('专利质量评价材料',res); 
            })
        },
        // closepdf() {
        //     this.filePath = '';
        //     this.showpdf = false;
        // },
        handlePreview_zlpj() {
            let that = this;
            if (this.zlpjlist && this.zlpjlist.id) {
                // this.showpdf = true;
                this.showpdf = !this.showpdf;
                this.filePath = this.zlpjlist.filePdfpath;
                // let routeData = this.$router.resolve({
                //     path: '/shenbao/pdfFile',
                //     query: {
                //         cxj_cxj_id: that.cxj_cxj_id,
                //         path: that.zlpjlist.filePdfpath
                //     }
                // });
                // window.open(routeData.href, '_blank');
            } else {
                this.$message.error('请上传文件');
            }
        },
        fileload_zlpj() {
            let that = this;
            if (this.zlpjlist && this.zlpjlist.id) {
                fileDownload({
                    cxj_cxj_id: that.cxj_cxj_id,
                    path: that.zlpjlist.fileDocpath
                }).then(res=>{
                    that.downfn('专利质量评价材料', res)
                })
            } else {
                this.$message.error('请上传文件');
            }
        },
        handleDownload_zlpj() {
            const choosefile = document.querySelector('#zlpj');
            choosefile.click();
        },
        handleDownloadzlpj() {
            let that = this;
            that.zlpj_percent = 0;
            that.zlpj_percent_flag = true;
            const files = document.getElementById('zlpj').files[0];
            console.log('24234234324',files)

            if (files) {
                if (files.size > 50*1024*1024) { // 此处判断上传文件的大小 , 单位为 b 故要乘以两个1024
                    this.$message.warning('文件最大为50兆')
                    return
                }
              if (files.name.substring(files.name.lastIndexOf('.')+1).toLowerCase()!='doc') { // 此处判断上传文件的大小 , 单位为 b 故要乘以两个1024
                this.$message.warning('请上传doc格式的文件')
                return
              }
                if(window.FileReader) { 
                    var fr = new FileReader(); 
                    fr.onprogress = function(e) { 
                        that.zlpj_percent = (e.loaded/files.size)*100;
                    };
                    fr.readAsDataURL(files); 
                }
                let formData = new FormData();
                formData.append('cxj_cxj_id', this.cxj_cxj_id)
                formData.append('file', files);
                if (this.zlpjlist && this.zlpjlist.id) {
                    formData.append('id', this.zlpjlist.id);
                } else {
                    formData.append('id', '');
                }
                zlsb_zlpjAdd(formData).then(res=>{
                    let data = res.data;
                    that.zlpj_percent_flag = false;
                    if (data.success) {
                        document.getElementById('zlpj').value = null;
                        that.$message.success('上传成功');
                        that.get_zlsb_getZlpj();
                    } else {
                        that.$message.error(data.message);
                    }
                }).catch(err=>{
                    console.log(err)
                    that.zlpj_percent_flag = false;
                })
            }
        },
        loadboard_jsxjx() {
            let that = this;
            cxjsb_downloadJsxjxmb({cxj_cxj_id:that.cxj_cxj_id}).then(res=>{
                that.downfn('技术先进性评价材料',res);  
            })
        },
        handlePreview_jsxjx() {
            let that = this;
            if (this.jsxjxlist && this.jsxjxlist.id) {
                // this.showpdf = true;
                this.showpdf = !this.showpdf;
                this.filePath = this.jsxjxlist.filePdfpath;
                // let routeData = this.$router.resolve({
                //     path: '/shenbao/pdfFile',
                //     query: {
                //         cxj_cxj_id: that.cxj_cxj_id,
                //         path: that.jsxjxlist.filePdfpath
                //     }
                // });
                // window.open(routeData.href, '_blank');
            } else {
                this.$message.error('请上传文件');
            }
        },
        fileload_jsxjx() {
            let that = this;
            if (this.jsxjxlist && this.jsxjxlist.id) {
                fileDownload({
                    cxj_cxj_id: that.cxj_cxj_id,
                    path: that.jsxjxlist.fileDocpath
                }).then(res=>{
                    that.downfn('技术先进性评价材料', res)
                })
            } else {
                this.$message.error('请上传文件');
            }
        },  
        handleDownload_jsxjx() {
            const choosefile = document.querySelector('#jsxjx');
            choosefile.click();
        },
        handleDownloadjsxjx() {
            let that = this;
            that.jsxjx_percent = 0;
            that.jsxjx_percent_flag = true;
            const files = document.getElementById('jsxjx').files[0];
            console.log('24234234324',files)
            if (files) {
                if (files.size > 50*1024*1024) { // 此处判断上传文件的大小 , 单位为 b 故要乘以两个1024
                    this.$message.warning('文件最大为50兆')
                    return
                }
              if (files.name.substring(files.name.lastIndexOf('.')+1).toLowerCase()!='doc') { // 此处判断上传文件的大小 , 单位为 b 故要乘以两个1024
                this.$message.warning('请上传doc格式的文件')
                return
              }
                if(window.FileReader) { 
                    var fr = new FileReader(); 
                    fr.onprogress = function(e) { 
                        that.jsxjx_percent = (e.loaded/files.size)*100;
                    };
                    fr.readAsDataURL(files); 
                }
                let formData = new FormData();
                formData.append('cxj_cxj_id', this.cxj_cxj_id)
                formData.append('file', files);
                if (this.jsxjxlist && this.jsxjxlist.id) {
                    formData.append('id', this.jsxjxlist.id);
                } else {
                    formData.append('id', '');
                }
                zlsb_jsxjxAdd(formData).then(res=>{
                    let data = res.data;
                    that.jsxjx_percent_flag = false;
                    if (data.success) {
                        document.getElementById('jsxjx').value = null;
                        that.$message.success('上传成功');
                        that.get_zlsb_getJsxjx();
                    } else {
                        that.$message.error(data.message);
                    }
                }).catch(err=>{
                    console.log(err)
                    that.jsxjx_percent_flag = false;
                })
            }
        },
        loadboard_bhcx1() {
            let that = this;
            cxjsb_downloadBh1mb({cxj_cxj_id:that.cxj_cxj_id}).then(res=>{
                that.downfn('保护措施和成效评价1',res);  
            })
        },
        handlePreview_bhcx1() {
            let that = this;
            if (this.bhcx1list && this.bhcx1list.id) {
                // this.showpdf = true;
                this.showpdf = !this.showpdf;
                this.filePath = this.bhcx1list.filePdfpath;
                // let routeData = this.$router.resolve({
                //     path: '/shenbao/pdfFile',
                //     query: {
                //         cxj_cxj_id: that.cxj_cxj_id,
                //         path: that.bhcx1list.filePdfpath
                //     }
                // });
                // window.open(routeData.href, '_blank');
            } else {
                this.$message.error('请上传文件');
            }
        },
        fileload_bhcx1() {
            let that = this;
            if (this.bhcx1list && this.bhcx1list.id) {
                fileDownload({
                    cxj_cxj_id: that.cxj_cxj_id,
                    path: that.bhcx1list.fileDocpath
                }).then(res=>{
                    that.downfn('保护措施和成效评价1', res)
                })
            } else {
                this.$message.error('请上传文件');
            }
        },
        handleDownload_bhcx1() {
            const choosefile = document.querySelector('#bhcx1');
            choosefile.click();
        },
        handleDownloadbhcx1() {
            let that = this;
            that.bhcx1_percent = 0;
            that.bhcx1_percent_flag = true;
            const files = document.getElementById('bhcx1').files[0];
            console.log('24234234324',files)
            if (files) {
                if (files.size > 50*1024*1024) { // 此处判断上传文件的大小 , 单位为 b 故要乘以两个1024
                    this.$message.warning('文件最大为50兆')
                    return
                }
              if (files.name.substring(files.name.lastIndexOf('.')+1).toLowerCase()!='doc') { // 此处判断上传文件的大小 , 单位为 b 故要乘以两个1024
                this.$message.warning('请上传doc格式的文件')
                return
              }
                if(window.FileReader) { 
                    var fr = new FileReader(); 
                    fr.onprogress = function(e) { 
                        that.bhcx1_percent = (e.loaded/files.size)*100;
                    };
                    fr.readAsDataURL(files); 
                }
                let formData = new FormData();
                formData.append('cxj_cxj_id', this.cxj_cxj_id)
                formData.append('file', files);
                if (this.bhcx1list && this.bhcx1list.id) {
                    formData.append('id', this.bhcx1list.id);
                } else {
                    formData.append('id', '');
                }
                zlsb_bh1Add(formData).then(res=>{
                    let data = res.data;
                    that.bhcx1_percent_flag = false;
                    if (data.success) {
                        document.getElementById('bhcx1').value = null;
                        that.$message.success('上传成功');
                        that.get_zlsb_getBh1();
                    } else {
                        that.$message.error(data.message);
                    }
                }).catch(err=>{
                    console.log(err)
                    that.bhcx1_percent_flag = false;
                })
            }
        },
        loadboard_bhcx2() {
            let that = this;
            cxjsb_downloadBh2mb({cxj_cxj_id:that.cxj_cxj_id}).then(res=>{
                that.downfn('保护措施和成效评价2',res);  
            })
        },
        handlePreview_bhcx2() {
            let that = this;
            if (this.bhcx2list && this.bhcx2list.id) {
                // this.showpdf = true;
                this.showpdf = !this.showpdf;
                this.filePath = this.bhcx2list.filePdfpath;
                // let routeData = this.$router.resolve({
                //     path: '/shenbao/pdfFile',
                //     query: {
                //         cxj_cxj_id: that.cxj_cxj_id,
                //         path: that.bhcx2list.filePdfpath
                //     }
                // });
                // window.open(routeData.href, '_blank');
            } else {
                this.$message.error('请上传文件');
            }
        },
        fileload_bhcx2() {
            let that = this;
            if (this.bhcx2list && this.bhcx2list.id) {
                fileDownload({
                    cxj_cxj_id: that.cxj_cxj_id,
                    path: that.bhcx2list.fileDocpath
                }).then(res=>{
                    that.downfn('保护措施和成效评价2', res)
                })
            } else {
                this.$message.error('请上传文件');
            }
        },  
        handleDownload_bhcx2() {
            const choosefile = document.querySelector('#bhcx2');
            choosefile.click();
        },
        handleDownloadbhcx2() {
            let that = this;
            that.bhcx2_percent = 0;
            that.bhcx2_percent_flag = true;
            const files = document.getElementById('bhcx2').files[0];
            console.log('24234234324',files)
            if (files) {
                if (files.size > 50*1024*1024) { // 此处判断上传文件的大小 , 单位为 b 故要乘以两个1024
                    this.$message.warning('文件最大为50兆')
                    return
                }
              if (files.name.substring(files.name.lastIndexOf('.')+1).toLowerCase()!='doc') { // 此处判断上传文件的大小 , 单位为 b 故要乘以两个1024
                this.$message.warning('请上传doc格式的文件')
                return
              }
                if(window.FileReader) { 
                    var fr = new FileReader(); 
                    fr.onprogress = function(e) { 
                        that.bhcx2_percent = (e.loaded/files.size)*100;
                    };
                    fr.readAsDataURL(files); 
                }
                let formData = new FormData();
                formData.append('cxj_cxj_id', this.cxj_cxj_id)
                formData.append('file', files);
                if (this.bhcx2list && this.bhcx2list.id) {
                    formData.append('id', this.bhcx2list.id);
                } else {
                    formData.append('id', '');
                }
                zlsb_bh2Add(formData).then(res=>{
                    let data = res.data;
                    that.bhcx2_percent_flag = false;
                    if (data.success) {
                        document.getElementById('bhcx2').value = null;
                        that.$message.success('上传成功');
                        that.get_zlsb_getBh2();
                    } else {
                        that.$message.error(data.message);
                    }
                }).catch(err=>{
                    console.log(err)
                    that.bhcx2_percent_flag = false;
                })
            }
        },
        loadboard_shxy() {
            let that = this;
            cxjsb_downloadShxymb_zl({cxj_cxj_id:that.cxj_cxj_id}).then(res=>{
                that.downfn('社会效益及发展前景评价',res);  
            })
        },
        handlePreview_shxy() {
            let that = this;
            if (this.shxylist && this.shxylist.id) {
                // this.showpdf = true;
                this.showpdf = !this.showpdf;
                this.filePath = this.shxylist.filePdfpath;
                // let routeData = this.$router.resolve({
                //     path: '/shenbao/pdfFile',
                //     query: {
                //         cxj_cxj_id: that.cxj_cxj_id,
                //         path: that.shxylist.filePdfpath
                //     }
                // });
                // window.open(routeData.href, '_blank');
            } else {
                this.$message.error('请上传文件');
            }
        },
        fileload_shxy() {
            let that = this;
            if (this.shxylist && this.shxylist.id) {
                fileDownload({
                    cxj_cxj_id: that.cxj_cxj_id,
                    path: that.shxylist.fileDocpath
                }).then(res=>{
                    that.downfn('社会效益及发展前景评价', res)
                })
            } else {
                this.$message.error('请上传文件');
            }
        },
        handleDownload_shxy() {
            const choosefile = document.querySelector('#shxy');
            choosefile.click();
        },
        handleDownloadshxy() {
            let that = this;
            that.shxy_percent = 0;
            that.shxy_percent_flag = true;
            const files = document.getElementById('shxy').files[0];
            console.log('24234234324',files)
            if (files) {
                if (files.size > 50*1024*1024) { // 此处判断上传文件的大小 , 单位为 b 故要乘以两个1024
                    this.$message.warning('文件最大为50兆')
                    return
                }
              if (files.name.substring(files.name.lastIndexOf('.')+1).toLowerCase()!='doc') { // 此处判断上传文件的大小 , 单位为 b 故要乘以两个1024
                this.$message.warning('请上传doc格式的文件')
                return
              }
                if(window.FileReader) { 
                    var fr = new FileReader(); 
                    fr.onprogress = function(e) { 
                        that.shxy_percent = (e.loaded/files.size)*100;
                    };
                    fr.readAsDataURL(files); 
                }
                let formData = new FormData();
                formData.append('cxj_cxj_id', this.cxj_cxj_id)
                formData.append('file', files);
                if (this.shxylist && this.shxylist.id) {
                    formData.append('id', this.shxylist.id);
                } else {
                    formData.append('id', '');
                }
                zlsb_shxyAdd(formData).then(res=>{
                    let data = res.data;
                    that.shxy_percent_flag = false;
                    if (data.success) {
                        document.getElementById('shxy').value = null;
                        that.$message.success('上传成功');
                        that.get_zlsb_getShxy();
                    } else {
                        that.$message.error(data.message);
                    }
                }).catch(err=>{
                    console.log(err)
                    that.shxy_percent_flag = false;
                })
            }
        },
        loadboard_hjqk() {
            let that = this;
            cxjsb_downloadHjqkmb({cxj_cxj_id:that.cxj_cxj_id}).then(res=>{
                that.downfn('获奖情况',res);  
            })
        },
        handlePreview_hjqk() {
            let that = this;
            if (this.hjqklist && this.hjqklist.id) {
                // this.showpdf = true;
                this.showpdf = !this.showpdf;
                this.filePath = this.hjqklist.filePdfpath;
                // let routeData = this.$router.resolve({
                //     path: '/shenbao/pdfFile',
                //     query: {
                //         cxj_cxj_id: that.cxj_cxj_id,
                //         path: that.hjqklist.filePdfpath
                //     }
                // });
                // window.open(routeData.href, '_blank');
            } else {
                this.$message.error('请上传文件');
            }
        },
        fileload_hjqk() {
            let that = this;
            if (this.hjqklist && this.hjqklist.id) {
                fileDownload({
                    cxj_cxj_id: that.cxj_cxj_id,
                    path: that.hjqklist.fileDocpath
                }).then(res=>{
                    that.downfn('获奖情况', res)
                })
            } else {
                this.$message.error('请上传文件');
            }
        },
        handleDownload_hjqk() {
            const choosefile = document.querySelector('#hjqk');
            choosefile.click();
        },
        handleDownloadhjqk() {
            let that = this;
            that.hjqk_percent = 0;
            that.hjqk_percent_flag = true;
            const files = document.getElementById('hjqk').files[0];
            console.log('24234234324',files)
            if (files) {
                if (files.size > 50*1024*1024) { // 此处判断上传文件的大小 , 单位为 b 故要乘以两个1024
                    this.$message.warning('文件最大为50兆')
                    return
                }
              if (files.name.substring(files.name.lastIndexOf('.')+1).toLowerCase()!='doc') { // 此处判断上传文件的大小 , 单位为 b 故要乘以两个1024
                this.$message.warning('请上传doc格式的文件')
                return
              }
                if(window.FileReader) { 
                    var fr = new FileReader(); 
                    fr.onprogress = function(e) { 
                        that.hjqk_percent = (e.loaded/files.size)*100;
                    };
                    fr.readAsDataURL(files); 
                }
                let formData = new FormData();
                formData.append('cxj_cxj_id', this.cxj_cxj_id)
                formData.append('file', files);
                if (this.hjqklist && this.hjqklist.id) {
                    formData.append('id', this.hjqklist.id);
                } else {
                    formData.append('id', '');
                }
                zlsb_hjqkAdd(formData).then(res=>{
                    let data = res.data;
                    that.hjqk_percent_flag = false;
                    if (data.success) {
                        document.getElementById('hjqk').value = null;
                        that.$message.success('上传成功');
                        that.get_zlsb_getHjqk();
                    } else {
                        that.$message.error(data.message);
                    }
                }).catch(err=>{
                    console.log(err)
                    that.hjqk_percent_flag = false;
                })
            }
        },
        loadboard_sjyd() {
            let that = this;
            cxjsb_downloadSjydmb({cxj_cxj_id:that.cxj_cxj_id}).then(res=>{
                that.downfn('设计要点及理念的表达评价材料',res);   
            })
        },
        handlePreview_sjyd() {
            let that = this;
            if (this.sjydlist && this.sjydlist.id) {
                // this.showpdf = true;
                this.showpdf = !this.showpdf;
                this.filePath = this.sjydlist.filePdfpath;
                // let routeData = this.$router.resolve({
                //     path: '/shenbao/pdfFile',
                //     query: {
                //         cxj_cxj_id: that.cxj_cxj_id,
                //         path: that.sjydlist.filePdfpath
                //     }
                // });
                // window.open(routeData.href, '_blank');
            } else {
                this.$message.error('请上传文件');
            }
        },
        fileload_sjyd() {
            let that = this;
            if (this.sjydlist && this.sjydlist.id) {
                fileDownload({
                    cxj_cxj_id: that.cxj_cxj_id,
                    path: that.sjydlist.fileDocpath
                }).then(res=>{
                    that.downfn('设计要点及理念的表达评价材料', res)
                })
            } else {
                this.$message.error('请上传文件');
            }
        },
        handleDownload_sjyd() {
            const choosefile = document.querySelector('#sjyd');
            choosefile.click();
        },
        handleDownloadsjyd() {
            let that = this;
            that.sjyd_percent = 0;
            that.sjyd_percent_flag = true;
            const files = document.getElementById('sjyd').files[0];
            console.log('24234234324',files)
            if (files) {
                if (files.size > 50*1024*1024) { // 此处判断上传文件的大小 , 单位为 b 故要乘以两个1024
                    this.$message.warning('文件最大为50兆')
                    return
                }
              if (files.name.substring(files.name.lastIndexOf('.')+1).toLowerCase()!='doc') { // 此处判断上传文件的大小 , 单位为 b 故要乘以两个1024
                this.$message.warning('请上传doc格式的文件')
                return
              }
                if(window.FileReader) { 
                    var fr = new FileReader(); 
                    fr.onprogress = function(e) { 
                        that.sjyd_percent = (e.loaded/files.size)*100;
                    };
                    fr.readAsDataURL(files); 
                }
                let formData = new FormData();
                formData.append('cxj_cxj_id', this.cxj_cxj_id)
                formData.append('file', files);
                if (this.sjydlist && this.sjydlist.id) {
                    formData.append('id', this.sjydlist.id);
                } else {
                    formData.append('id', '');
                }
                zlsb_sjydAdd(formData).then(res=>{
                    let data = res.data;
                    that.sjyd_percent_flag = false;
                    if (data.success) {
                        document.getElementById('sjyd').value = null;
                        that.$message.success('上传成功');
                        that.get_zlsb_getSjyd();
                    } else {
                        that.$message.error(data.message);
                    }
                }).catch(err=>{
                    console.log(err)
                    that.sjyd_percent_flag = false;
                })
            }
        },
        downfn(title, res) {
            const data = res.data;
            const url = window.URL.createObjectURL(new Blob([data], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}))
            const link = document.createElement('a')
            link.style.display = 'none'
            link.href = url;
            link.setAttribute('download', title+'.doc')
            document.body.appendChild(link)
            link.click()
            document.body.removeChild(link)
        },
        getCxjsbGetCxjByid(){
            cxjsbGetCxjByid({
                cxj_cxj_id: this.$route.query.cxj_cxj_id
            }).then(res=>{
                if (res.data.code=='200') {
                    this.cxjinfo = res.data.result;
                    this.xl_id = this.cxjinfo.xl_id;
                }
            })
        },
    },
    mounted() {
        this.cxj_cxj_id = this.$route.query.cxj_cxj_id;
        this.init();
        this.getCxjsbGetCxjByid();
    }
}
</script>
<style lang="less" scoped>
.declareTableInfo {
    margin-top: 24px;
    padding-bottom: 30px;
    border-bottom: 1px solid #EEEEEE;
    input {
        display: none;
    }
    .flex_box {
        display: flex;
    }
    .title {
        display: flex;
        justify-content: space-between;
        align-items: center;
        span {
            font-size: 16px;
            font-family: PingFangSC-Medium, PingFang SC;
            font-weight: 500;
            color: #3388EE;
            line-height: 22px;
            em {
                color: #cb0c0c;
                font-style: normal;
                font-size:  14px;;
            }
        }
        .btnList {
            button{
                width: 70px;
                height: 32px;
                border: 1px solid #D9D9D9;
                font-size: 14px;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                color: #333333;
                line-height: 20px;
                margin-left: 10px;
                &.download {
                    color: #fff;
                }
                &.loadboard {
                    width: 100px;
                }
            }
        }
    }
    .tableList {
        margin-top: 21px;
        table {
            margin-top: 20px;
            background: #FFFFFF;
            thead {
                background: #F5F5F5;
                tr {
                    th {
                        height: 54px;
                        font-size: 16px;
                        font-family: PingFangSC-Medium, PingFang SC;
                        font-weight: 500;
                        color: #333333;
                    }
                }
            }
            tbody {
                tr {
                    height: 52px;
                    td {
                        color: #444444;
                        font-size: 14px;
                        font-weight: 400;
                        height: 52px;
                        em {
                            color: #CB0C0C;
                            margin-right: 5px;
                        }
                    }
                    &:nth-child(even){
                        background: #F5F5F5;
                    }
                }
            }
        }
    }
}
</style>
